package com.example.kotlinlearndemo.kotlin


class Child2 {
    companion object {
        var foo: Child2? = null

        fun getInstance(): Child2 {
            println("getInstance")
            if (foo == null) {
                foo = Child2()
            }
            return foo!!
        }
    }

    fun foo() {
        println("foo")
    }
}

class Child : Parent1(), Interface1, Interface2 {

    var a: String? = null
    var child2: Child2 = Child2.getInstance()

    override fun fun2() {
        fun1()
    }

    fun foo(a: String) {

    }
}

fun main() {
    val list= mutableListOf<String>()

    list.add("1")
    list.add("2")
    list.add("3")

    val list2=list.toMutableList()

    list.clear()

    list2.forEach {
        println(it)
    }
}